package net.shopxx.service.impl;

import java.util.List;

import javax.annotation.Resource;

import net.shopxx.dao.IndexflooradvDao;
import net.shopxx.entity.Indexfloor;
import net.shopxx.entity.Indexflooradv;
import net.shopxx.service.IndexflooradvService;

import org.hibernate.Hibernate;
import org.springframework.stereotype.Service;
import org.springmodules.cache.annotations.Cacheable;

/**
 * Service实现类 - 首页楼层轮播图
 */

@Service
public class IndexflooradvServiceImpl extends BaseServiceImpl<Indexflooradv, String> implements IndexflooradvService {

	@Resource
	private IndexflooradvDao indexflooradvDao;
	
	@Resource
	public void setBaseDao(IndexflooradvDao indexflooradvDao) {
		super.setBaseDao(indexflooradvDao);
	}
	
	@Cacheable(modelId = "caching")
	public List<Indexflooradv> getEnabledIndexflooradvList() {
		List<Indexflooradv> enabledIndexflooradvList = indexflooradvDao.getEnabledIndexflooradvList();
		if (enabledIndexflooradvList != null) {
			for (Indexflooradv enabledIndexflooradv : enabledIndexflooradvList) {
				Hibernate.initialize(enabledIndexflooradv);
			}
		}
		return enabledIndexflooradvList;
	}
	
	@Cacheable(modelId = "caching")
	public List<Indexflooradv> getEnabledIndexflooradvList(Indexfloor indexfloor) {
	    List<Indexflooradv> enabledIndexflooradvList = indexflooradvDao.getEnabledIndexflooradvList(indexfloor);
	    if (enabledIndexflooradvList != null) {
            for (Indexflooradv enabledIndexflooradv : enabledIndexflooradvList) {
                Hibernate.initialize(enabledIndexflooradv);
            }
        }
        return enabledIndexflooradvList;
	}
	
	

}